package com.sinosoft.dsp.persistence.businessconcept.atom;

import javax.measure.unit.Unit;

/**
 * 范围对象
 * 
 * @author 潘巍（Peter Pan）
 * @since 2011-4-23 下午04:28:34
 */
public class SinoRangeBean<T> implements ISinoRangeAtomType {
	// 最小范围
	private SinoQuantityBean<T> min;

	// 最大范围
	private SinoQuantityBean<T> max;

	// 是否包含最小范围
	private boolean includeLower;

	// 是否包含最小范围
	private boolean includeUpper;

	public SinoQuantityBean<T> getMin() {
		return min;
	}

	public SinoRangeBean<T> setMin(SinoQuantityBean<T> min) {
		this.min = min;
		return this;
	}

	public SinoRangeBean<T> setMin(T num, Unit<?> unit) {
		this.min = new SinoQuantityBean<T>(num, unit);
		return this;
	}

	public SinoQuantityBean<T> getMax() {
		return max;
	}

	public SinoRangeBean<T> setMax(SinoQuantityBean<T> max) {
		this.max = max;
		return this;
	}

	public SinoRangeBean<T> setMax(T num, Unit<?> unit) {
		this.max = new SinoQuantityBean<T>(num, unit);
		return this;
	}

	public boolean isIncludeLower() {
		return includeLower;
	}

	public void setIncludeLower(boolean includeLower) {
		this.includeLower = includeLower;
	}

	public boolean isIncludeUpper() {
		return includeUpper;
	}

	public void setIncludeUpper(boolean includeUpper) {
		this.includeUpper = includeUpper;
	}

	@Override
	public boolean isEmpty() {
		return this.min.isEmpty() && this.max.isEmpty();
	}

	@Override
	public boolean hasLower() {
		return this.min != null && !this.min.isEmpty();
	}

	@Override
	public boolean hasUpper() {
		return this.max != null && !this.max.isEmpty();
	}

}
